﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SoIM
{
    /// <summary>
    /// 用户节点
    /// </summary>
    /// <remarks>2013-10-30 by sutroon</remarks>
    public partial class ucUserNode : UserControl, IUserNode
    {
        public int NodeIndex { get; set; }
        public string ImagePath { get { return this.picFace.ImageLocation; } set { if (!string.IsNullOrEmpty(value)) this.picFace.LoadAsync(value); } }
        public string NodeText { get { return this.lblName.Text; } set { this.lblName.Text = value; } }
        int nodelevel;
        public int NodeLevel
        {
            get { return nodelevel; }
            set
            {
                nodelevel = value;
                this.Margin = new Padding(value * 20, 3, 3, 3);
            }
        }
        public NodeStates NodeState { get; set; }
        public ucUserNode()
        {
            InitializeComponent();
            cmsClickEventConfig();
        }

        private void cmsClickEventConfig()
        {
            cmi查看资料.Click += new EventHandler(cmi_Click);
            cmi开始对话.Click += new EventHandler(cmi_Click);
        }

        private void cmi_Click(object sender, EventArgs e)
        {
            switch (((ToolStripMenuItem)sender).Name)
            {
                case "cmi查看资料":
                    break;
                case "cmi开始对话":
                    if (this.Tag == null)
                    {
                        MessageBox.Show("数据有误!");
                        return;
                    }
                    //new frmMessageDialog() { UserName = this.NameText, UserFace = picFace.Image,TargetIP=((System.Xml.Linq.XElement)this.Tag).Attribute("LoginIP").Value }.Show();
                    new frmMessageLAN() { UserName = this.NodeText, UserFace = picFace.Image,TargetIP=((System.Xml.Linq.XElement)this.Tag).Attribute("LoginIP").Value }.Show();
                    break;
            }
        }

    }
}
